package com.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.bean.Title;
import com.utils.DateBase;

public class Queryt {
	public List<Title> query(){
		Title title = new Title();
		List<Title> list=new ArrayList<Title>();
		Connection cnn = DateBase.getConnention();
		String sql = " select titlename,name,date from title ";
		PreparedStatement ps;
		try {
			ps = cnn.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();
			
			while (rs.next()) {
				title = new Title();
				title.setTitle(rs.getString("titlename"));
				title.setName(rs.getString("name"));
				title.setDate(rs.getString("date"));
				list.add(title);
			}
			rs.close();
			ps.close();
			cnn.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

}
